{include file="common/Header.html"}
<body class="body-main">
<div class="admin_notice">
	<span>管理操作：</span><select onChange="self.location.href='?Admin-article-Index-cid-'+this.value+''">
			<option value="">所有分类</option>
			{$class_option}
			</select> ┊ <a href="{'Admin/Article/edit'|url}">添加文档</a> ┊ <a class="hand" id="search">搜索文档</a></div>
<br>
<ul id="admin_sub_title">
	<li class="unsub"><a href="{'Admin/Article/index'|url}">文档管理</a></li>
	<li class="sub"><a>{if $id==0}添加{else}编辑{/if}文档</a></li>
</ul>
<script>
$(function() {
	$("#search").click(function(){
		art.dialog({
			id:'s',
			title:'搜索',
			content:'关键词：<input name="keyword" type="text" class="input" id="keyword" value="" />',
			ok: function(){
				if($('#keyword').val()!='') location.href="?Admin-Article-index-q-"+$('#keyword').val();
			}
		});
	});
});
</script>
<style type="text/css">
dd { float:left }
</style>
<div id="admin_right_b">
  <form method="post">
    <table width="98%" border="0" align="center" cellpadding="3" cellspacing="2" id="tagContent0">
	<tr>
      <td width="120" align="right" class="tdbg">标题：</td>
	  <input type="hidden" name="con[id]" value="{$id|default:0}">
      <td class="tdbg">
		<dd><input name="con[title]" type="text" value="{$title}" class="input" size="50"></dd>
		<dd>&nbsp;<select name="con[style1]">
				<option value="" >默认</option>
				<option value="color:#CC0000;" style="color:#CC0000;"{if stripos($style,'color:#CC0000;')>-1} selected{/if}>红色</option>
				<option value="color:#0000FF;" style="color:#0000FF;"{if stripos($style,'color:#0000FF;')>-1} selected{/if}>蓝色</option>
				<option value="color:#009900;" style="color:#009900;"{if stripos($style,'color:#009900;')>-1} selected{/if}>绿色</option>
				<option value="color:#996600;" style="color:#996600;"{if stripos($style,'color:#996600;')>-1} selected{/if}>咖啡色</option>
				<option value="color:#8142BF;" style="color:#8142BF;"{if stripos($style,'color:#8142BF;')>-1} selected{/if}>紫色</option>
				<option value="color:#FF6600;" style="color:#FF6600;"{if stripos($style,'color:#FF6600;')>-1} selected{/if}>橘黄色</option>
			</select>
			<select name="con[style2]">
				<option value="" >默认</option>
				<option value="font-weight:bold;"{if stripos($style,'font-weight:bold;')>-1} selected{/if}>加粗</option>
				<option value="text-decoration:underline;"{if stripos($style,'text-decoration:underline;')>-1} selected{/if}>下划线</option>
			</select></dd>
	  
	  </td>
    </tr>
	
	<tr>
      <td align="right">文章属性：</td>
      <td>
		{foreach $flaglist as $vo}
			<input{if stripos($flag,$vo['en'])>-1} checked{/if} name="con[flag][]" type="checkbox" value="{$vo['en']}" /> {$vo['cn']}
		{/foreach}
	  </td>
    </tr>

	<tr>
      <td align="right">所属栏目：</td>
      <td><select name="con[cid]">{$class_option}</select>
	  </td>
    </tr>

	<tr>
      <td align="right">来源：</td>
      <td>
		<dd>
			<input name="con[source]" class="input" type="text" style="width:90px;" value="{$source|default:'互联网'}">
		</dd>
		<dd>&nbsp;作者：</dd>
		<dd>
			<input name="con[writer]" class="input" type="text" style="width:90px;" value="{$writer|default:$adminid}">
		</dd>
		<dd>&nbsp;发布时间：</dd>
		<dd>
			<input name="con[addtime]" type="text" onClick="WdatePicker({ dateFmt:'yyyy-MM-dd HH:mm:ss'})" class="input Wdate" style="width:150px;" value="{if $addtime}{$addtime|date:'Y-m-d H:i:s'}{else}{$default_day}{/if}">
		</dd>
	  </td>
    </tr>
	<tr>
      <td align="right">状态：</td>
      <td><input style="display: inline;height: 1em;border:0;background:none;" name="con[isshow]" type="radio" value="1" {if $isshow==1 or $isshow==''}checked{/if} />已审 
		<input style="display: inline;height: 1em;border:0;background:none;" name="con[isshow]" type="radio" value="0" {if $isshow=='0'}checked{/if}/>未审
	  </td>
	</tr>
	<tr>
      <td align="right">缩略图：</td>
      <td><input type="text" name="con[litpic]" class="input" size="60" id="litpicfile" value="{$litpic}" /> <span class="ke-button-common ke-button-outer"><input type="button" id="filemanager" value="选择图片" class="ke-button-common ke-button" /></span></td>
    </tr>
	
	<tr>
      <td align="right">关键词：</td>
      <td><input name="con[keywords]" type="text" value="{$keywords}" class="input" size="65"></td>
    </tr>

	<tr>
	  <td align="right">摘要：</td>
      <td valign="top"><textarea name="con[description]" style="width:530px;height:70px;" >{$description}</textarea>
	  </td>
    </tr>

	<tr>
      <td align="right">内容：</td>
      <td><input name="remote" id="remote" type="checkbox" value="1" /> 远程图片自动下载&nbsp;&nbsp;<input name="autolitpic" id="autolitpic" type="checkbox" value="1" /> 提取第一个图片为缩略图</td>
    </tr>

    <tr class="tdbg">
      <td align="center"></td>
      <td valign="top"><textarea id="body" name="con[body]" style="width:650px;height:320px;" >{$body}</textarea>
	  </td>
    </tr>

	<tr>
      <td align="right">排序：</td>
      <td><input name="con[order]" type="text" value="{$order|default:0}" class="input" size="10"> <span>越大排越前面</span></td>
    </tr>

	<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" >
		<tr class="tdbg">
		  <td width="100">&nbsp;</td>
		  <td><div class="aui_buttons"  style="text-align:left;"><button type="submit" id="dosave" class="aui_state_highlight">保存</button><button type="reset" class="aui_state_highlight">重置</button><button type="button" onClick="history.go(-1)" class="aui_state_highlight">返回</button></div></td>
		</tr>
	</table>
 </form>
<script type="text/javascript">
editor=KindEditor.create('#body',{
	resizeType : 1,
	allowPreviewEmoticons : false,
	allowImageUpload : true,
	fileManagerJson : "?g=Plus&m=Editor&a=fileManager",
	allowFileManager : true,
	items : [
		'source','preview','|','undo','redo', '|','fontname','fontsize', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
		'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', '|', 'emoticons', 'image', 'multiimage', 'baidumap','|','link','unlink','|','code','fullscreen']
});
$('#filemanager').click(function() {
	editor.loadPlugin('image', function() {
		editor.plugin.imageDialog({
			imageUrl : $('#litpicfile').val(),
			clickFn : function(url, title, width, height, border, align) {
				$('#litpicfile').val(url);
				//$('#litpic').attr('src',url);
				editor.hideDialog();
			}
		});
	});
});
$("#dosave").click(function(){
	if($("#remote").attr("checked")==true){
		body=editor.html();
		var autolitpic=($("#autolitpic").attr("checked")) ? 1 : 0;
		msgdialog=art.dialog({
			id:'savepic',
			title:'提示',
			lock:true,
			content:"<img src='static/images/load_blue.gif' /><br>保存远程图片中..."
		});
		$.ajax({
			type:"post",
			url:"{'Admin/Article/downBodyImg'|url}",
			data:"body="+encodeURIComponent(body),
			dataType:'text',
			timeout:120000,
			global:false,
			success:function(data){
				editor.html(data);
				msgdialog.content("<img src='static/images/load_blue.gif' /><br>图片保存成功！正在保存文章..");
				setTimeout("msgdialog.close();",500);
				setTimeout("savearticle();",500);
			}
		});
	}else{
		savearticle();
	}
	return false;
});
function savearticle(){
	editor.sync('#body');
	showDialog();
	$.ajax({
		type:"post",
		url:"{'Admin/Article/update'|url}",
		data:$("form").serialize(),
		dataType:'json',
		timeout:28000,
		global:false,
		success:function(data){
			if(data.status==1){
				showAlert('success','恭喜你，修改成功',data.url);
			}else{
				showAlert('error',data.info);
			}
		}
	});
}
</script>
<div class="runtime"></div>  
</div>
</body>
</html>